function weights = createWeightsMatrix( memorizingPatterns )
% CREATEWEIGHTSMATRIX 
%
% Autor: 
%        Grupo 2
% Descripcion:
%        Esta funcion genera la matriz de pesos de la red de
%        hopfield.
% Input:
%        Los patrones a ser memorizados
% Output:
%        La matriz de pesos de la red

global N;

weights = zeros(N,N);
valuesToCalculate = (N*(N-1))/2;

i = 1;
j = 2;
for y = 1:valuesToCalculate
  weights(i,j) = sum(memorizingPatterns(i,:).*memorizingPatterns(j,:));
  weights(j,i) = weights(i,j);
  j = j+1;
  if j > N
      i = i+1;
      j = i+1;
  end
end

weights = (1/N) * weights;

%weights = zeros(N,N);
%valuesToCalculate = (N*(N-1))/2;

%for x = 1:P
%   pattern = memorizingPatterns{x};
%   pattern = matrixToVector(pattern);
%   i = 1;
%   j = 2;
%   for y = 1:valuesToCalculate
%      weights(i,j) = weights(i,j) + pattern(i)*pattern(j);
%      weights(j,i) = weights(i,j);
%      j = j+1;
%      if j > N
%          i = i+1;
%          j = i+1;
%      end
%   end
%end
%
%weights = (1/N) * weights;

end

